$(function() {
    init_vue();
});

function init_vue() {
    var vue = new Vue({
        el : "#myapp",
        data : {
            organization_bank_list : null,
            organization_list : null,
        },
        filters:{
            city_text:function(value, code){
                return areaSelect.returnTextByCode(value, code);;
            }
        },
        events : {
			'scanCodeWin':function (src) {
                this.$broadcast('openScanCodeWin', src);
            },
            'refreshOrganizationBankList':function () {
                this.getData();
            },
            'refreshCustomerInfo': function (r) {
                var t = this;
                for (var i=0; i<t.organization_bank_list.length; i++) {
                    if (t.organization_bank_list[i].id == r.organizationBank.id) {
                        for(var p in r.organizationBank) {
                            var name=p;//属性名称
                            t.organization_bank_list[i][name]=r.organizationBank[p];
                        }
                    }
                }
            }
        },
        methods : {
            init : function() {
                close_layuiLayerLoad();
                this.getData();
            },
            getData : function() {
                showLoad();
                var t = this;
                postMsg(root+"/organization/toOrganizationBank", {"t":"1"}, function(i) {
                    t.organization_bank_list = null;
                    t.organization_list = null;
                    t.organization_bank_list = i.organization_bank_list;
                    t.organization_list = i.organization_list;
                    hideLoad();
                });
            },
            openBindBankWin : function () {
                var t = this;
                var organizationBank = new Object();
                for(var p in t.organization_bank_list[0]) {
                    var name=p;//属性名称
                    var value=t.organization_bank_list[0][p];//属性对应的值
                    organizationBank[name]=t.organization_bank_list[0][p];
                }
                // organizationBank["money"] = 0;
                this.$broadcast('openWin', {title:"签约资料", organizationBank:organizationBank, type:2, info:""});
            },
            openRechargeSmallAmountWin : function () {
                /*if (this.organization_bank_list.length == 0) {
                    this.openBindBankWin();
                } else {

                }*/
                this.$broadcast('openOrganizationRechargeWin');
            },
            openRechargeWithdrawalsWin : function () {
                var organizationBank = new Object();
                if (this.organization_bank_list.length == 0) {
                    organizationBank.id = 0;
                    organizationBank.bank_name = "";
                    organizationBank.bank_no = "";
                    organizationBank.province = "";
                    organizationBank.city = "";
                    organizationBank.bank_address = "";
                    organizationBank.cardholder = "";
                    organizationBank.identity = "";
                    organizationBank.mobile_phone = "";
                    organizationBank.money = 0;
                } else {
                    var t = this;
                    for(var p in t.organization_bank_list[0]) {
                        var name=p;//属性名称
                        var value=t.organization_bank_list[0][p];//属性对应的值
                        organizationBank[name]=t.organization_bank_list[0][p];
                    }
                    organizationBank["money"] = 0;
                }

                this.$broadcast('openWin', {title:"出金申请", organizationBank:organizationBank, type:3, info:''});
            },
            rechargeLargeAmount : function () {
                var organizationBank = new Object();
                if (this.organization_bank_list.length == 0) {
                    organizationBank.id = 0;
                    organizationBank.bank_name = "";
                    organizationBank.bank_no = "";
                    organizationBank.province = "";
                    organizationBank.city = "";
                    organizationBank.bank_address = "";
                    organizationBank.cardholder = "";
                    organizationBank.identity = "";
                    organizationBank.mobile_phone = "";
                    organizationBank.money = 0;
                } else {
                    var t = this;
                    for(var p in t.organization_bank_list[0]) {
                        var name=p;//属性名称
                        var value=t.organization_bank_list[0][p];//属性对应的值
                        organizationBank[name]=t.organization_bank_list[0][p];
                    }
                    organizationBank["money"] = 0;
                }

                this.$broadcast('openWin', {title:"入金申请", organizationBank:organizationBank, type:1, info:''});
            }
        }
    });
    vue.init();
}